#ifndef THINK_THINK_PAGINATOR_DRIVER_BOOTSTRAP_H
#define THINK_THINK_PAGINATOR_DRIVER_BOOTSTRAP_H

static char* think_paginator_driver_bootstrap =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: zhangyajun <448901948@qq.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\paginator\\driver;\n"
	"\n"
	"use think\\Paginator;\n"
	"\n"
	"class Bootstrap extends Paginator\n"
	"{\n"
	"\n"
	"    /**\n"
	"     * 上一页按钮\n"
	"     * @param string $text\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getPreviousButton($text = \"&laquo;\")\n"
	"    {\n"
	"\n"
	"        if ($this->currentPage() <= 1) {\n"
	"            return $this->getDisabledTextWrapper($text);\n"
	"        }\n"
	"\n"
	"        $url = $this->url(\n"
	"            $this->currentPage() - 1\n"
	"        );\n"
	"\n"
	"        return $this->getPageLinkWrapper($url, $text);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 下一页按钮\n"
	"     * @param string $text\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getNextButton($text = \'&raquo;\')\n"
	"    {\n"
	"        if (!$this->hasMore) {\n"
	"            return $this->getDisabledTextWrapper($text);\n"
	"        }\n"
	"\n"
	"        $url = $this->url($this->currentPage() + 1);\n"
	"\n"
	"        return $this->getPageLinkWrapper($url, $text);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 页码按钮\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getLinks()\n"
	"    {\n"
	"        if ($this->simple)\n"
	"            return \'\';\n"
	"\n"
	"        $block = [\n"
	"            \'first\'  => null,\n"
	"            \'slider\' => null,\n"
	"            \'last\'   => null\n"
	"        ];\n"
	"\n"
	"        $side   = 3;\n"
	"        $window = $side * 2;\n"
	"\n"
	"        if ($this->lastPage < $window + 6) {\n"
	"            $block[\'first\'] = $this->getUrlRange(1, $this->lastPage);\n"
	"        } elseif ($this->currentPage <= $window) {\n"
	"            $block[\'first\'] = $this->getUrlRange(1, $window + 2);\n"
	"            $block[\'last\']  = $this->getUrlRange($this->lastPage - 1, $this->lastPage);\n"
	"        } elseif ($this->currentPage > ($this->lastPage - $window)) {\n"
	"            $block[\'first\'] = $this->getUrlRange(1, 2);\n"
	"            $block[\'last\']  = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage);\n"
	"        } else {\n"
	"            $block[\'first\']  = $this->getUrlRange(1, 2);\n"
	"            $block[\'slider\'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);\n"
	"            $block[\'last\']   = $this->getUrlRange($this->lastPage - 1, $this->lastPage);\n"
	"        }\n"
	"\n"
	"        $html = \'\';\n"
	"\n"
	"        if (is_array($block[\'first\'])) {\n"
	"            $html .= $this->getUrlLinks($block[\'first\']);\n"
	"        }\n"
	"\n"
	"        if (is_array($block[\'slider\'])) {\n"
	"            $html .= $this->getDots();\n"
	"            $html .= $this->getUrlLinks($block[\'slider\']);\n"
	"        }\n"
	"\n"
	"        if (is_array($block[\'last\'])) {\n"
	"            $html .= $this->getDots();\n"
	"            $html .= $this->getUrlLinks($block[\'last\']);\n"
	"        }\n"
	"\n"
	"        return $html;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 渲染分页html\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function render()\n"
	"    {\n"
	"        if ($this->hasPages()) {\n"
	"            if ($this->simple) {\n"
	"                return sprintf(\n"
	"                    \'<ul class=\"pager\">%s %s</ul>\',\n"
	"                    $this->getPreviousButton(),\n"
	"                    $this->getNextButton()\n"
	"                );\n"
	"            } else {\n"
	"                return sprintf(\n"
	"                    \'<ul class=\"pagination\">%s %s %s</ul>\',\n"
	"                    $this->getPreviousButton(),\n"
	"                    $this->getLinks(),\n"
	"                    $this->getNextButton()\n"
	"                );\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成一个可点击的按钮\n"
	"     *\n"
	"     * @param  string $url\n"
	"     * @param  int    $page\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getAvailablePageWrapper($url, $page)\n"
	"    {\n"
	"        return \'<li><a href=\"\' . htmlentities($url) . \'\">\' . $page . \'</a></li>\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成一个禁用的按钮\n"
	"     *\n"
	"     * @param  string $text\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getDisabledTextWrapper($text)\n"
	"    {\n"
	"        return \'<li class=\"disabled\"><span>\' . $text . \'</span></li>\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成一个激活的按钮\n"
	"     *\n"
	"     * @param  string $text\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getActivePageWrapper($text)\n"
	"    {\n"
	"        return \'<li class=\"active\"><span>\' . $text . \'</span></li>\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成省略号按钮\n"
	"     *\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getDots()\n"
	"    {\n"
	"        return $this->getDisabledTextWrapper(\'...\');\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 批量生成页码按钮.\n"
	"     *\n"
	"     * @param  array $urls\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getUrlLinks(array $urls)\n"
	"    {\n"
	"        $html = \'\';\n"
	"\n"
	"        foreach ($urls as $page => $url) {\n"
	"            $html .= $this->getPageLinkWrapper($url, $page);\n"
	"        }\n"
	"\n"
	"        return $html;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成普通页码按钮\n"
	"     *\n"
	"     * @param  string $url\n"
	"     * @param  int    $page\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getPageLinkWrapper($url, $page)\n"
	"    {\n"
	"        if ($page == $this->currentPage()) {\n"
	"            return $this->getActivePageWrapper($page);\n"
	"        }\n"
	"\n"
	"        return $this->getAvailablePageWrapper($url, $page);\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif